package com.sjksy.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sjksy.demo.domain.Employee;
import com.sjksy.demo.domain.Guide;
import com.sjksy.demo.dto.employee.EmployeeDto;
import com.sjksy.demo.mapper.EmployeeMapper;
import com.sjksy.demo.service.GuideService;
import com.sjksy.demo.mapper.GuideMapper;
import com.sjksy.demo.vo.employee.EmployeeResponseVo;
import com.sjksy.demo.vo.employee.GuideVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author guyueyuan
* @description 针对表【guide】的数据库操作Service实现
* @createDate 2024-12-11 15:37:02
*/
@Service
public class GuideServiceImpl extends ServiceImpl<GuideMapper, Guide>
    implements GuideService{
    @Resource
    private GuideMapper guideMapper;
    @Resource
    private EmployeeMapper employeeMapper;


    /**
     * 查询所有导游
     * @return
     */
    public List<GuideVo> searchGuide() {
        List<Guide> guides=guideMapper.selectList(null);

        List<GuideVo> list=new ArrayList<>();

        guides.forEach(guide -> {

           EmployeeDto employeeDto= employeeMapper.getGuide(guide.getEmployeeId());

            GuideVo guideVo=GuideVo.builder()
                    .employeeId(guide.getEmployeeId())
                    .guideId(guide.getGuideId())
                    .name(employeeDto.getName())
                    .idCardNumber(employeeDto.getIdCardNumber())
                    .branchName(employeeDto.getBranchName())
                    .empType("导游")
                    .guideNumber(guide.getGuideNumber())
                    .guideLevel(guide.getGuideLevel())
                    .build();
            list.add(guideVo);
        });
        return list;
    }
}




